package com.design.flyweight.demo;

public class FlyweightDemo {
    public static void main(String[] args) {
        // 创建两个相同内容的字符串
        String str1 = "Hello";
        String str2 = "Hello";

        // 判断两个字符串是否为同一个对象
        System.out.println("str1 == str2: " + (str1 == str2)); // 输出：str1 == str2: true

        // 创建两个不同内容的字符串
        String str3 = new String("Hello");
        String str4 = new String("Hello");

        // 判断两个字符串是否为同一个对象
        System.out.println("str3 == str4: " + (str3 == str4)); // 输出：str3 == str4: false

        // 判断两个字符串内容是否相等
        System.out.println("str1.equals(str3): " + str1.equals(str3)); // 输出：str1.equals(str3): true

        System.out.println("str1.equals(str4): " + str1.equals(str4));

        System.out.println("str3.equals(str4): " + str3.equals(str4));
    }
}
